<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模版字符串</title>
</head>
<body>
    <div class="box">
    </div>

    <script>
        // 模版字符串: 使用tab键上面的反引号``, 插入变量时使用${变量名}
        const oBox = document.querySelector('.box');
        let id = 1,name = '模版字符串';
        let htmlStr = `<ul>
            <li>
                <p id=${id}>${name}</p>
            </li>
        </ul>`;

        // oBox.innerHTML = "<ul><li><p id="+id+">"+name+"</p></li></ul>";
        oBox.innerHTML = htmlStr;

    </script>
    
</body>
</html>